<template>
  <div>
    {{ deptName }}
  </div>
</template>

<script>
export default {
  name: "DeptTag",
  props: ["deptId"],
  data() {
    return {
      deptData: null
    }
  },
  created() {
    const localCache = require('@/plugins/cache').default.local;
    this.deptData = localCache.getJSON('deptData');
  },
  computed: {
    deptName() {
      console.log('sss')
      if (this.deptData == null) {
        return '';
      } else {
        let name = '';
        this.deptData.data.forEach(d => {
          if (d.deptId == this.deptId) {
            name = d.deptName;
          }
        });
        return name;
      }
    }
  }
};
</script>
<style scoped>
.el-tag+.el-tag {
  margin-left: 10px;
}
</style>